local skel = fk.CreateSkill {
  name = "lb__tongzhou",
  max_branches_use_time = {
    ["damage"] = {
      [Player.HistoryRound] = 1
    },
  }
}

Fk:loadTranslationTable {
  ["lb__tongzhou"] = "同舟",
  --[":lb__tongzhou"] = "每回合限一次，当一名角色受到伤害时，你可以重置任意名横置角色，然后与你横置状态相同的角色各摸一张牌。 ",
  --10.5
  [":lb__tongzhou"] = "每轮限一次，当一名角色受到伤害时，你可以重置任意名横置角色，然后与你横置状态相同的角色各摸一张牌。 ",

  ["#lb__tongzhou"] = "同舟：你可以重置任意名横置角色，然后与你横置状态相同的角色各摸一张牌",

  ["$lb__tongzhou1"] = "群龙，依此号令。",
  ["$lb__tongzhou2"] = "烈腾八荒，荡除凶灾！",
}

skel:addEffect(fk.DamageInflicted, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player:usedSkillTimes(skel.name, Player.HistoryRound, "damage") < 1 and
    table.find(player.room:getAlivePlayers(), function(to)
      return to.chained
    end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = table.filter(room:getAlivePlayers(), function(t)
      return t.chained
    end)
    if #tos == 0 then return end
    tos = room:askToChoosePlayers(player, {
      targets = tos,
      min_num = 1,
      max_num = 999,
      skill_name = skel.name,
      cancelable = true,
      prompt = "#lb__tongzhou",
    })
    room:sortByAction(tos)
    event:setCostData(self, { tos = tos })
    return #tos > 0
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, "damage")
    local room = player.room
    local tos = event:getCostData(self).tos
    for _, to in ipairs(tos) do
      if not to.dead and to.chained then
        to:setChainState(false)
      end
    end
    if player.dead then return end
    tos = table.filter(room:getAlivePlayers(), function(t)
      return t.chained == player.chained
    end)
    room:doIndicate(player, tos)
    for _, to in ipairs(tos) do
      if not to.dead then
        to:drawCards(1, skel.name)
      end
    end
  end,
}, { check_skill_limit = true})

return skel